package org.mspring.platform.security.dao.impl;

import org.mspring.platform.dao.hibernate.GenericDao;
import org.mspring.platform.security.dao.UserDao;
import org.mspring.platform.security.entity.User;
import org.springframework.stereotype.Repository;

/**
 * @author Gao Youbo
 * @since 2014年1月4日
 */
@Repository
public class UserDaoImpl extends GenericDao<User, Long> implements UserDao {

    @Override
    public User findUser(String username, String password) {

        return super.uniqueResult("select user from User user where user.name = ? and user.password = ?", username, password);
    }

    @Override
    public User findByUsername(String username) {

        return super.uniqueResult("select user from User user where user.name = ?", username);
    }

    @Override
    public User findByEmail(String email) {
        return super.uniqueResult("select user from User user where user.email = ?", email);
    }

    @Override
    public User findByAlias(String alias) {
        return super.uniqueResult("select user from User user where user.alias = ?", alias);
    }

}
